{% extends "base.html" %}

{% block content %}
<h1>Account list</h1>

<p class="description">Click the account you want to use.</p>

<div class="list account-list">
	<h2>Accounts</h2>
	{% if accounts %}
		<table class="table-list" cellpadding="0" cellspacing="0">
			<tr class="header">
				<th class="first string account-title">Account</th>
				<th class="date account-lastupdated">Last Updated</th>
				<th class="last number account-balance">Bank Balance</th>
			</tr>
			{% for accounts_by_type in accounts|groupby('account_type') %}
				<tr class="subheader">
					<td colspan="3" class="first last account-type">{{ accounts_by_type.grouper }}</td>
				</tr>
				{% for account in accounts_by_type.list %}
					<tr>
				        <td class="first string account-title"><a href="/account/view?key={{ account.key() }}">{{ account.title }}</a></td>
				        <td class="date account-lastupdated">DD/MM/YYYY</td>
				        <td class="last number account-balance">0.00 &euro;</td>
				    </tr>
				{% endfor %}
				<tr class="subfooter">
					<td colspan="3" class="first last account-subtotal">Subtotal: {{ accounts_by_type.list|sum(attribute='initial_amount')|float(0.00) }} &euro;</td>
				</tr>
			{% endfor %}
			<tr class="footer">
				<td colspan="3" class="first last account-total">Total Account Balance: {{ accounts|sum(attribute='initial_amount')|float(0.00) }} &euro;</td>
			</tr>
		</table>
	{% endif %}
</div>

{% endblock %}
